/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package structures.parserStructures;

import java.util.LinkedList;
import java.util.List;
import structures.tree.ParseTreeNode;

/**
 *
 * @author Vlad
 */
public class Stack {

    private List<StackElem> stack = new LinkedList<StackElem>();

    public void push(StackElem el) {
        stack.add(el);
    }

    public List<ParseTreeNode> popM(int m) {
        List<ParseTreeNode> res = new LinkedList<ParseTreeNode>();
        for (StackElem el : stack.subList(stack.size() - m, stack.size())) {
            res.add(el.getNode());
        }
        stack = stack.subList(0, stack.size() - m);
        return res;
    }

    public StackElem getHead() {
        return stack.get(stack.size() - 1);
    }
}
